<?php

require_once(dirname(__FILE__) . "/NewNamesFinder.php");
ini_set('memory_limit', '50M');




$request_uri = $_SERVER["REQUEST_URI"];
if(preg_match("/[&\?]url=(.*)$/", $request_uri, $arr)) $url = $arr[1];
else $url = @$_REQUEST['url'];
$freeText = @$_REQUEST['freeText'];


if(!$url && !$freeText)
{
    echo "please enter a url or some freeText<br/>\n";
    echo "/service.php?url=<br/>\n";
    echo "/service.php?freeText=";
    exit;
}

$name_finder = new NewNamesFinder();
if($url) $freeText = @file_get_contents($url);
$names = $name_finder->find_names($freeText);

header('Content-type: text/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n";
echo "<results xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n";
echo "  <allNames>\n";

foreach($names as $name=>$score)
{
    echo "    <entity>\n";
    echo "      <nameString>".htmlspecialchars(trim($name))."</nameString>\n";
    echo "      <nov_ranks>".htmlspecialchars(trim($score))."</nov_ranks>\n";
    echo "    </entity>\n";
}

echo "  </allNames>\n";
echo "</results>";




?>